<?php
include_once(dirname(__FILE__).'/../inc_all.php');
if(!$_POST['yong_hu_ming'])
{
	echo '<script language="javascript">alert(\'用户名不能为空！\');window.history.go(-1);</script>';
	exit;
}
if(!$_POST['mi_ma'])
{
	echo '<script language="javascript">alert(\'密码不能为空！\');window.history.go(-1);</script>';
	exit;
}
if(!$_POST['yan_zheng_ma'])
{
	echo '<script language="javascript">alert(\'验证码不能为空！\');window.history.go(-1);</script>';
	exit;
}
if($_POST['yan_zheng_ma'] != $_SESSION['ht_check_code'])
{
	echo '<script language="javascript">alert(\'验证码错误！\');window.history.go(-1);</script>';
	exit;
}
$data = G('db')->query_once("select * from ylt_ht_yong_hu where yong_hu_ming = '".MRES($_POST['yong_hu_ming'])."' and mi_ma = '".MRES(jia_mi($_POST['mi_ma'], 'sha1'))."'");
if(!$data)
{
	echo '<script language="javascript">alert(\'用户名或密码错误！\');window.history.go(-1);</script>';
	exit;
}
//清除验证码session
$_SESSION['ht_check_code'] = '';
//设置session
set_session('id_yong_hu', $data['id_yong_hu']);			//用户id
set_session('quan_xian', $data['quan_xian']);				//权限
set_session('ni_cheng', $data['ni_cheng']);					//昵称
//更新登录信息
G('db')->query("update ylt_ht_yong_hu set sj_fang_wen = '".date('Y-m-d H:i:s')."', ip_fang_wen = '".get_user_ip()."'");
//跳转到主界面
header("location:index.php");
?>